<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>编辑菜单</title>
    
    	<link href="__ADMIN_CSS__/bootstrap.min.css" rel="stylesheet">
	<link href="__ADMIN_AWESOME__/css/font-awesome.css" rel="stylesheet">
	<link href="__ADMIN_CSS__/animate.css" rel="stylesheet">
	<link href="__ADMIN_CSS__/style.css" rel="stylesheet">
	<style type="text/css">
		.menu-icon {		
			width: 24px;
			height: 24px;
			margin-left: -4px;
			background: url("__ADMIN_IMG__/admin-icon/menu.png") no-repeat;

		}
		#current a{
			color: #18A689;
		}

        body{
            font-family: "微软雅黑",Helvetica,Tahoma,Arial,sans-serif;
        }
        .operation_nav{
        	margin: 0px;
        	padding: 0px;
        	height: 36px;
        	list-style:none;
        	background: rgba(0, 0, 0, 0) url("__ADMIN_IMG__/hr.png") repeat-x scroll 0 bottom;
        }
       
        .operation_nav li {
        	float: left;
		    color: #18A689;
		    font-weight: 700;
		    line-height: 33px;
        }

        .operation_nav .current{
    	    border-bottom: 2px solid #18A689;
        }
        .operation_nav li a {
        	color: #666;
    	    float: left;
		    padding: 0 15px;
		    text-align: center;
        }
        .operation_nav .none a:hover {
        	border-bottom: 2px solid #ccc;
        }

	    .cate_line{
	    	width:24px;
	    	background:url("__ADMIN_IMG__/cate_line.png") center center repeat-y;
	    }
	    .cate_end{
	    	width:24px;
	    	background:url("__ADMIN_IMG__/cate_end.png") center center no-repeat;
	    }
	    .cate_middle{
	    	width:24px;
	    	background:url("__ADMIN_IMG__/cate_middle.png") center center no-repeat;
	    }
	    @media screen and (max-width: 768px) {
	 		.cate_line{
		    	background:none;
		    }
		    .cate_end{
		    	background:none;
		    }
		    .cate_middle{
		    	background:none;
		    }
		}
	</style>
	<script type="text/javascript">
		var APP_TMPL_PATH = "<?php echo (APP_TMPL_PATH); ?>";
		var NOW_PATH ="<?php echo U();?>";
	</script>
</head>
<body>
    <div id="wrapper">
        <nav class="navbar-default navbar-static-side" role="navigation">
            
<div class="sidebar-collapse">
    <ul class="nav" id="side-menu">
        <?php if(is_array($MenuJson["child"])): $i = 0; $__LIST__ = $MenuJson["child"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$group): $mod = ($i % 2 );++$i;?><li class="active">
                <a href="#" data-id=""><i class="fa "></i><span class="nav-label"><b><?php echo ($key); ?></b></span><span class="fa arrow"></span></a>
                 <?php if(is_array($group)): $i = 0; $__LIST__ = $group;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><ul class="nav nav-second-level">
                        <li><a href="" data-id=""><?php echo ($vo["name"]); ?></a></li>
                    </ul><?php endforeach; endif; else: echo "" ;endif; ?>
            </li><?php endforeach; endif; else: echo "" ;endif; ?>
    </ul>

</div>

        </nav>
        <div id="page-wrapper" class="gray-bg">
        <div class="row border-bottom" >
            <nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0px;">
                        <div class="navbar-header">
            <a class="navbar-minimalize minimalize-styl-2 btn btn-primary " href="#"><i class="fa fa-bars"></i> </a>
            <ul class="nav navbar-top-links navbar-left" id="admin_top_nav">
                <?php if(is_array($MenuJson["top"])): $i = 0; $__LIST__ = $MenuJson["top"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><li id="<?php echo (($vo["active"])?($vo["active"]):''); ?>"><a href="#" title="<?php echo ($vo["name"]); ?>" data-id=""><?php echo ($vo["name"]); ?></a></li><?php endforeach; endif; else: echo "" ;endif; ?>
            </ul>
        </div>
            <ul class="nav navbar-top-links navbar-right">               
                <li>
                    <a href="login.html">
                        <i class="fa  menu-icon" ></i> Log out fa-sign-out
                    </a>
                </li>
            </ul>

            </nav>
        </div>
        <div class="wrapper  animated fadeInRight">
            <br/>
            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox-title">  
                        
    <ul class="operation_nav">
        <li class="none"><a href="<?php echo U('Admin/Menu/index');?>">后台菜单列表</a></li>
        <li class="none"><a href="<?php echo U('Admin/Menu/index');?>">添加菜单</a></li>
    </ul>   
  
                    </div>      
                </div>
                <div class="col-lg-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-content" style="border-top:none;">
                             
    <form method="post" class="form-horizontal" action="__SELF__">
    <div class="form-group"><label class="col-sm-2 control-label">菜单名称</label>
        <div class="col-sm-4"><input type="text" name="name" value="<?php echo ($menu["name"]); ?>" class="form-control"></div>
    </div>
    <div class="form-group"><label class="col-sm-2 control-label">上级菜单</label>

        <div class="col-sm-4">
            <select class="form-control m-b" name="parent">
                <option value="0">顶级菜单</option>
                <?php if(is_array($menuArr)): $i = 0; $__LIST__ = $menuArr;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option value="<?php echo ($vo["id"]); ?>" <?php if($vo["id"] == $menu['parent']): ?>selected=""<?php endif; ?> ><?php echo ($vo["title_show"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
            </select>
        </div>
    </div>
    <div class="form-group"><label class="col-sm-2 control-label">菜单URL</label>
        <div class="col-sm-4">
            <input type="text" name="url" class="form-control" value="<?php echo ($menu["url"]); ?>">
        </div>
    </div>
    <div class="form-group"><label class="col-sm-2 control-label">菜单说明</label>
        <div class="col-sm-4">
            <input type="text" name="description" class="form-control" value="<?php echo ($menu["description"]); ?>">
        </div>
    </div>
    <div class="form-group"><label class="col-sm-2 control-label">菜单排序</label>
        <div class="col-sm-2">
            <input type="text" name="sort"  class="form-control" value="<?php echo ($menu["sort"]); ?>">
        </div>
    </div>
    <div class="form-group"><label class="col-sm-2 control-label">是否隐藏</label>

        <div class="col-sm-10">
          
            <div class="radio i-checks"><label> 
                <input type="radio" <?php if($menu['status'] == 0): ?>checked="checked"<?php endif; ?>value="1" name="status"> <i></i>是</label>
            </div>
            <div class="radio i-checks"><label> 
                <input type="radio" <?php if($menu['status'] == 1): ?>checked="checked"<?php endif; ?> value="0" name="status"> <i></i>否</label>
            </div>
        </div>
    </div>
    <input type="hidden"  name="id" class="form-control" value="<?php echo ($_GET['id']); ?>">

    <div class="form-group">
        <div class="col-sm-4 col-sm-offset-2">
            <button class="btn btn-primary" type="submit">保存</button>
        </div>
    </div>
</form>

                        </div>
                    </div>
                </div>
            </div>
        </div>
          		<div class="footer">
            <div>
                <strong>Copyright</strong> jiangfei &copy; 2014-2015
            </div>
        </div>
        </div>
        </div>
        <!-- Mainly scripts -->
    <script src="__ADMIN_JS__/jquery-2.1.1.js"></script>

    <script src="__ADMIN_JS__/bootstrap.min.js"></script>
    <script src="__ADMIN_JS__/plugins/metisMenu/jquery.metisMenu.js"></script>
    <script src="__ADMIN_JS__/plugins/slimscroll/jquery.slimscroll.min.js"></script>
    <!-- Custom and plugin javascript -->
    <script src="__ADMIN_JS__/inspinia.js"></script>
    <script src="__ADMIN_JS__/plugins/pace/pace.min.js"></script>
    <script type="text/javascript" src="__ADMIN_JS__/message.js"></script>
    <script type="text/javascript">
        $("form").submit(function(){
            var self = $(this);
            $.post(self.attr("action"), self.serialize(), success, "json");
            return false;

            function success(data){
                if(data.status){
                    showMsg(data.info,data.url,'success',2000);
                } else {
                    showMsg(data.info,data.url,'',2000);
                }
            }

            function showMsg(info , url , option ,time) {
                if(!option) {
                    option = "default";
                }
                var msg = new $.Messager(info, {type:option,placement: 'center',time: 1000});
                msg.show();
                setTimeout("location.href= '" + url + "';", 1000);  
            }
        });
    </script>
    <script type="text/javascript">
        $(function () {
            var flag = false;
            var nowPath = NOW_PATH.toLowerCase();
            var op_arr = $('.operation_nav li').find('a');
            op_arr.each(function() {
                var href = $(this).attr('href').toLowerCase(); 
                if(href == nowPath) {
                    $(this).parent().addClass('current').removeClass('none');
                    flag = true;
                }
            })
            // if(flag == false) {
            //     op_arr = $('.operation_nav').find('li:first').addClass('current').removeClass('none');
            // }
        })

    </script>
    <script type="text/javascript">
    //     var MenuJson = <?php echo $MenuJson ?>;

    //     $(function () {
    //         var html = [];
    //         $.each(MenuJson, function (i, o) {
    //             html.push('<li >'+'<a href="#" title="' + o.name + '" data-id="' + o.id + '">' + o.name + '</a></li>');
    //         });
    //         $('#admin_top_nav').html(html.join(''));
    //         $('#admin_top_nav li:last > a').click();
    //         setInterval(function(){
    //             online();
    //         }, 60000);
            
    //     });
    //     //一级导航点击
    //     $('#admin_top_nav').on('click', 'a', function (e) {
    //         //取消事件的默认动作
    //         e.preventDefault();
    //         //终止事件 不再派发事件
    //         e.stopPropagation();
    //         var data_id = $(this).attr('data-id');
    //         var html = [],
    //             child_index = 0,
    //             child_html = [];
    //             data_list = MenuJson[data_id],
    //             B_menubar = $('#side-menu');
    //         //显示左侧菜单
    //         show_left_menu(data_list['items']);
    //         $('#side-menu').html(html.join('')).attr('data-id', data_id);

    //         //显示左侧菜单
    //         function show_left_menu(data) {
    //             for (var attr in data) {
    //                 if (data[attr] && typeof (data[attr]) === 'object') {
    //                     //循环子对象
    //                     if (!data[attr].url && attr === 'items') {
    //                         //子菜单添加识别属性
    //                         $.each(data[attr], function (i, o) {
    //                             child_index++;
    //                             o.isChild = true;
    //                             o.child_index = child_index;
    //                         });
    //                     }
    //                     show_left_menu(data[attr]); //继续执行循环(筛选子菜单)
    //                 } else {
    //                     if (attr === 'name') {
    //                         data.url = data.url ? data.url : '#';
    //                         if (!(data['isChild'])) {
    //                             //一级菜单
    //                             html.push('<li><a href="' + data.url + '" data-id="' + data.id + '"><i class="fa menu-icon"></i><span class="nav-label"><b>' + data.name + '</b></span><span class="fa arrow"></span></a>');
    //                         } else {
    //                             //二级菜单
    //                             child_html.push('<li><a href="' + data.url + '" data-id="' + data.id + '">' + data.name + '</a></li>');

    //                             //二级菜单全部push完毕
    //                             if (data.child_index == child_index) {
    //                                 html.push('<ul class="nav nav-second-level">' + child_html.join('') + '</ul></li>');
    //                                 child_html = [];
    //                             }
    //                         }
    //                     }
    //                 }
    //             }
    //         };
    //         $('#side-menu').metisMenu();
    //     });
        // $('#admin_top_nav').on('click', 'a', function (e ) {
        //     e.preventDefault();
        // //终止事件 不再派发事件
        //     e.stopPropagation();

        //     var html = [],
        //     child_index = 0,
        //     child_html = [];
        //     var data_id = $(this).attr('data-id'),
        //     data_list = MenuJson[data_id];
        //     show_left_menu(data_list['items']);
        //     $("#side-menu").html(html.join('')).attr('data-id', data_id);
        //       function show_left_menu(data) {
        //     for(var value in data) {
            
        //         if(data[value] && typeof (data[value]) == 'object') {

        //             if (!data[value].url && value === 'items') {
        //                 var datas = data[value];
        //                 for(var values in datas) {
        //                      //二级菜单
        //                     if(values === 'url') {
        //                         child_html.push('<li><a href="' + datas.url + '" data-id="' + datas.id + '">' + datas.name + '</a></li>');
        //                     }

        //                 }
        //                 var flag = true;
        //             }
                    
        //             //show_left_menu(data[value]); //继续执行循环(筛选子菜单)

        //         }else{
        //             if(value === 'name') {
        //                 data.url = data.url ? data.url : '#';
        //                 if(!(data['isChild'])) {
        //                     html.push('<li class="active"><a href="#" data-id="' + data.id + '"><i class="fa '+ data.icon +'"></i><span class="nav-label"><b>' + data.name + '</b></span><span class="fa arrow"></span></a>');
        //                 }
        //             }else {
        //                 //二级菜单
        //                 if(value === 'url' && data['isChild']) {
        //                     child_html.push('<li><a href="' + data.url + '" data-id="' + data.id + '">' + data.name + '</a></li>');
        //                 }
        //                 //if(flag == true) {
        //                     html.push('<ul class="nav nav-second-level">' + child_html.join('') + '</ul></li>');
        //                 //}
        //                 // //二级菜单全部push完毕
        //                 // if (data.child_index > 2) {


        //                 //     if(child_html != '') {
        //                 //        html.push('<ul class="nav nav-second-level">' + child_html.join('') + '</ul></li>'); 
        //                 //     }
        //                 //     child_html = [];
        //                 // }
        //             }
        //         }
        //     }
        // }
        // $('#side-menu').metisMenu();
        // });
    </script>
   




</body>

</html>